import requests
from bs4 import BeautifulSoup
from urllib.parse import urljoin

def fetch_page(url):
    try:
        response = requests.get(url)
        response.raise_for_status()  # Raise an HTTPError for bad responses
        return response.text
    except requests.RequestException as e:
        print(f"Error fetching URL {url}: {e}")
        return None

def parse_and_extract_links(html_content, base_url):
    soup = BeautifulSoup(html_content, 'html.parser')
    links = []
    for link in soup.find_all('a'):
        href = link.get('href')
        if href:
            full_url = urljoin(base_url, href)
            links.append(full_url)
    return links

def main():
    base_url = "https://fanqienovel.com/keyword/1707828418"
    html = fetch_page(base_url)
    if html:
        links = parse_and_extract_links(html, base_url)
        print("Found links:")
        for link in links:
            print(link)
    else:
        print("No HTML content to parse.")

if __name__ == "__main__":
    main()